<!--
จำเป็นต้องมีสำหรับ หน้า print
div => "head" ถูกแสดงด้านบนทุกหน้า
thead => "tableHead" หัวตารางที่จะถูกแสดงทุกหน้า
2 => "" หัวตารางที่จะถูกแสดงทุกหน้า
tr => "row[no]" แถวในตาราง, class => "row"
td => class => "rowTd" ใช้หาความสูงแดวตารางใน IE
tr => "emptyRow" แถวว่างท้ายตาราง
4 => "foot" แสดงที่ส่วนท้ายทุกหน้า
-->
<div id="divFirstHeader"></div>  <div class="header">
    <div class="title">
        <?php echo $this->element('print/title'); ?>
        <table>
            <tr>
                <td width="120px"><label>Vendor</label></td>
                <td><?php echo $this->data['Supplier']['name']; ?></td>
            </tr>
        </table>
    </div>
    <div class="documentTitle">
        <div class="documentNote">DISPATCH NOTE</div>
        <table class="documentNo">
            <tr>
                <td><label>Vendor no.</label></td>
                <td><?php echo $this->data['Supplier']['code']; ?></td>
                <td><label>Dispatch no.</label></td>
                <td><?php echo $this->data['SDH']['dispatch_no']; ?></td>
            </tr>
        </table>
        <table>
            <tr>
                <td><label>Date</label> <?php echo $this->data['SDH']['dispatch_date']; ?></td>
                <td width="50px"><label>Page</label></td>
                <td><span class="pageNo">1/1</span></td>
            </tr>
            <tr>
                <td width="100px"><label>Delivered To</label></td>
                <td colspan="2"><?php echo $this->data['SDH']['delivered_to']; ?></td>
            </tr>
            <tr>
                <td><label>To Warehouse</label></td>
                <td colspan="2"><?php echo $this->data['SDH']['to_warehouse']; ?></td>
            </tr>
        </table>
    </div>
    <br />
    <table class="tableTitle">
        <tr>
            <td width="120px"><label>Customer no.</label></td>
            <td width="290px"><?php echo $this->data['Customer']['cust_no']; ?></td>
            <td width="105px"><label>Site no.</label></td>
            <td><?php echo $this->data['Site']['site_no']; ?></td>
        </tr>
        <tr>
            <td><label>Customer Name</label></td>
            <td><?php echo $this->data['Customer']['name']; ?></td>
            <td><label>Site Name</label></td>
            <td><?php echo $this->data['Site']['name']; ?></td>
        </tr>
    </table>
    <br />&nbsp;
</div>

<div class="main">
    <table id="dataTable" class="dataTable" cellspacing="0" cellpadding="0" >
        <thead id="tableHead">
            <tr align="center">
                <th width="35px">Item<br>ลำดับ</th>
                <th width="100px">Part Number<br>รหัสสินค้า</th>
                <th>Description<br>รายการ</th>
                <th width="45px">Qty<br>จำนวน</th>
                <th width="45px">Unit<br>หน่วย</th>
                <th width="70px">Price/Unit<br>ราคา/หน่วย</th>
                <th width="70px">Amount<br>จำนวนเงิน</th>
            </tr>
        </thead>
        <tbody id="tableBody">
            <?php
            $i = 0;
            $total = 0;
            foreach ($this->data['SD'] as $sd) :
            ?>
                <tr id="row<?php echo $i; ?>" class="row">
                    <td class="center rowTd"><?php echo++$i; ?></td>
                    <td><?php echo $sd['Product']['supplier_part_no']; ?></td>
                    <td><?php echo!empty($sd['CPS']['text']) ? $sd['CPS']['text'] : $sd['Product']['text']; ?></td>
                    <td class="text-right"><?php echo $sd['qty']; ?></td>
                    <td class="center"><?php echo $sd['Product']['Unit']['title']; ?></td>
                    <td class="text-right"><?php echo number_format($sd['price'], 2); ?></td>
                    <td class="text-right">
                    <?php
                    $amount = $sd['price'] * $sd['qty'];
                    $total += $amount;
                    echo number_format($amount, 2);
                    ?>
                </td>
            </tr>
            <?php
                    //$ps_count = count($sd['ProductSerial']);
                    $k = 0;
                    foreach ($sd['ProductSerial'] as $ps) :
            ?>
                        <tr class="product_serials_row">
                            <td>&nbsp;</td>
                            <td class="rowTd">
                                <span class="product_serial_no"><?php echo++$k; ?>&nbsp;</span>
                                <span><?php echo!empty($ps['serial_no']) ? $ps['serial_no'] : 'N/A' ?></span>
                            </td>
                            <td>
                                <span><?php echo!empty($ps['other_information']) ? $ps['other_information'] : 'N/A' ?></span>
                            </td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
            <?php endforeach; ?>
            <?php endforeach; ?>
            <?php for ($i = 0; $i < 20; ++$i) : ?>
                            <tr class="emptyRow"> <!-- สร้างแถวเปล่าขึ้นมาเพื่อยืดขนาดตารางให้เต็มหน้า-->
                                <td class="rowTd">&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
                            </tr>
            <?php endfor; ?>
                        </tbody>
                        <tfoot>
                            <tr>
                                <td class="text-right" colspan="6">Total</td>
                                <td class="text-right"><?php echo number_format($total, 2); ?></td>
                            </tr>
                        </tfoot>                                
                    </table>
                </div>
                <br />
                <div class="footer">
                    <div class="remark" style="width: 28em;">
                        <label>Remark</label><br />
        <?php echo $this->data['SDH']['remark']; ?>
                        </div>
                        <div class="custSignature" style="padding-left: 0px;">
                            <hr />
                            <span>Customer/Date</span>
                        </div>
                        <div class="custSignature" style="padding-left: 0px;">
                            <hr />
                            <span>Vendor/Date</span>
                        </div>
    <?php //debug($this->data);    ?>
</div>